package model

import (
	"errors"
	"github.com/dailing/levlog"
)

type PictureBelongsTo struct {
	Id        int64
	PatientID int64
	PictureID int64
	UserID    int64
	WhichEye  string
	ResultRaw string
}

func NewPicturePatientsRelation(pic, pat int64) *PictureBelongsTo {
	return &PictureBelongsTo{
		PatientID: pat,
		PictureID: pic,
	}
}

func (*PictureBelongsTo) Delete() error {
	panic("implement me")
}

func (p *PictureBelongsTo) Get() error {
	succ, err := engine.Get(p)
	if !succ {
		return errors.New("No such record")
	}
	return err
}

func (p *PictureBelongsTo) Update() error {
	_, err := engine.
		Id(p.Id).
		Cols("result_raw").
		Update(p)
	levlog.E(err)
	return err
}

func (p *PictureBelongsTo) Insert() error {
	_, err := engine.Insert(p)
	levlog.E(err)
	return err
}
